<%-- 
    Document   : thanhtoan
    Created on : Dec 1, 2011, 11:01:21 AM
    Author     : BlueZky
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>


<c:set var="sum" value="0"></c:set>
<c:set var="soluong" value="0"></c:set>
<c:set var="khuyenmai" value="0"></c:set>
<c:forEach items="${sessionScope.gioHang}" var="item" varStatus="status">
    <c:set var="sum" value="${sum + item.gia*item.soluongton}"></c:set>
    <c:set var="soluong" value="${soluong + item.soluongton}"></c:set>
</c:forEach>


<div class="u-subcontent">
    <div class="utitle">
        Giỏ hàng
    </div>
    <div class="box">
        <div class="cart-box">
            <a href="">
                <img src="images/cart.gif" height="170px"/>
            </a>
        </div>
        <div class="cart-box" style="border:none; width: 420px;" cell-spacing="0px">
            <table  style="width: 100%;" cellspacing ="20px" >
                <tr style="border-bottom: 1px #ccc solid;" >
                    <td class="detail-left">Số sản phẩm</td>
                    <td class="detail-right"><b>${soluong}</b></td>
                </tr>
                <tr style="border-bottom: 1px #ccc solid;" >
                    <td class="detail-left" >Thành tiền</td>
                    <td class="detail-right" style="color:green; font-weight: bold;">${sum} $</td>
                </tr>
                <tr style="border-bottom: 1px #ccc solid;" >
                    <td class="detail-left">Khuyến mãi</td>
                    <td class="detail-right"><b>${khuyenmai} $</b></td>
                </tr>
                <tr style="border-bottom: 1px #ccc solid;" >
                    <td class="detail-left">Thanh toán</td>
                    <td class="detail-right">
                        <b style="color: green;">${sum - khuyenmai} $</b>
                    </td>
                </tr>
            </table>

        </div>
    </div>
    <div style="clear:both;"></div>

    <div class="utitle">
        Danh sách chi tiết
    </div>
    <div class="box">
        <c:if test="${sessionScope.gioHang.size() gt 0}">
            <form method="POST" action="giohang.htm" id="gioHang">
                <input type="hidden" name="a" value="u"/>
                <table class="utable" cellspacing="0px" cellpadding="10px" >
                    <tr>
                        <th style="width:20px;">STT</th>
                        <th>Sản phẩm</td>
                        <th style="width:50px;">Số lượng</th>
                        <th style="width:70px;">Đơn giá</th>
                        <th style="width:70px;">Khuyến mãi</th>
                        <th style="width:100px;">Thành tiền</th>
                        <th style="border-right: none;"></th>
                    </tr>
                    <c:forEach items="${sessionScope.gioHang}" var="item" varStatus="status">
                        <tr >
                            <td>${status.index + 1}</td>
                            <td><a href="chitiet.htm?PID=${item.masp}" style="color: #00CED1;">${item.tensp}</a></td>
                            <td style="text-align: right">${item.soluongton}</td>
                            <td style="text-align: right">${item.gia}</td>
                            <td style="text-align: right">0</td>
                            <td style="border-right: none;"><b>${item.soluongton*item.gia}</b></td>
                            <td style="border-right: none;"><a href="giohang.htm?a=d&pid=${item.masp}"><img src="images/delete.png" width="28px" alt="delete" /></a></td>
                        </tr>
                    </c:forEach>
                    <tr>

                        <td style="border: none;"></td>
                        <td style="border: none;"><div class="btn-buy" 
                                                       style="font-size: 20px; 
                                                       font-family: sans-serif; 
                                                       padding: 0 10px 0 10px;
                                                       cursor: pointer;" 
                                                       onclick="capNhatGioHang()">
                                <input type="image" src="images/Refresh.png" align="middle"/>Cập nhật</div></td>

                        <td style="border: none;" colspan="3">
                            <a href="thanhtoan.htm"><div class="btn-buy" style="font-size: 20px; font-family: sans-serif; padding: 0 10px 0 10px;">
                                <img src="images/Package.png" alt="Thanh toán" align="middle"/> Thanh toán
                            </div></a>
                        </td>
                        <td style="border: none;"></td>
                    </tr>
                </table>
            </form>
        </c:if>
    </div>

</div>